//
//  MotiveManager.m
//  TheProjectName
//
//  Created by 李劲成 on 16/5/26.
//  Copyright © 2016年 sunzhichao. All rights reserved.
//

#import "MotiveManager.h"

@interface MotiveManager ()

@property (nonatomic, strong) NSString *imageName;


@end

@implementation MotiveManager

+(instancetype)shareMotiveManager{
    static MotiveManager *manager;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [self new];
    });
    
    return manager;
}

- (instancetype)init{
    self = [super init];
    if (self) {
        self.imageName = [[NSUserDefaults standardUserDefaults]objectForKey:@"skinId"];
        if (_imageName) {
               NSString *path = [[NSBundle mainBundle]pathForResource:_imageName ofType:@"jpg"];
               self.backImage = [UIImage imageWithContentsOfFile:path];
        }
        else{
            NSString *path = [[NSBundle mainBundle]pathForResource:@"1" ofType:@"jpg"];
            self.backImage = [UIImage imageWithContentsOfFile:path];
        }
     
    
        
    }
    return self;
}


- (void)changeBackImageWithName:(NSString *)name AndType:(NSString *)type{
    NSString *path = [[NSBundle mainBundle]pathForResource:name ofType:type];
    self.backImage = [UIImage imageWithContentsOfFile:path];
    [[NSUserDefaults standardUserDefaults]setObject:name forKey:@"skinId"];
    [[NSNotificationCenter defaultCenter]postNotificationName:@"changeSkin" object:nil userInfo:nil];
}

@end
